<template>
  <div>
    <!-- 这里是一张图片文章-->
    <div
      @click="$router.push({path:'/postdetails?id='+post.id})"
      v-if="post.cover.length === 1 && post.type === 1"
      class="postsOne"
    >
      <div class="post-left">
        <p class="hot-title">{{post.title}}</p>
        <div class="bom-info">
          <span>{{post.user.nickname}}</span>
          <span>{{post.comment_length}}跟帖</span>
        </div>
      </div>
      <div class="post-right">
        <img :src="post.cover[0].url" alt />
      </div>
    </div>
    <!-- 这里是三张图片文章 -->
    <div
      @click="$router.push({path:'/postdetails?id='+post.id})"
      v-else-if="post.cover.length === 3 && post.type === 1"
      class="postsTwo"
    >
      <div class="title">
        <p>{{post.title}}</p>
      </div>
      <div class="center_img">
        <img :src="post.cover[0].url" alt />
        <img :src="post.cover[1].url" alt />
        <img :src="post.cover[2].url" alt />
      </div>
      <div class="bom-info">
        <span>{{post.user.nickname}}</span>
        <span>{{post.comment_length}}跟帖</span>
      </div>
    </div>
    <!-- 这里是视频文章 -->
    <div @click="$router.push({path:'/postdetails?id='+post.id})" v-else class="postsThree">
      <div class="title">
        <p>{{post.title}}</p>
      </div>
      <div class="center_video">
        <span class="iconfont iconshipin"></span>
        <img :src="post.cover[0].url" alt />
      </div>
      <div class="bom-info">
        <span>{{post.user.nickname}}</span>
        <span>{{post.comment_length}}跟帖</span>
      </div>
    </div>

    <!-- 样式3结束 -->
  </div>
</template>
<script>
export default {
  props: ["post"]
};
</script>

<style lang="less" scoped>
//封装函数
.common_title() {
  font-size: 16px;
  color: #333;
}
.common_posts() {
  display: flex;
  flex-wrap: wrap;
  //   align-posts: center;
  padding: 24px 8px 15px 8px;
  border-bottom: 1px solid #e4e4e4;
}
.common_bomInfo() {
  font-size: 14px;
  color: #868686;
  span:first-child {
    margin-right: 14px;
  }
}
//新闻样式1
.postsOne {
  display: flex;
  padding: 24px 8px 15px 8px;
  border-bottom: 1px solid #e4e4e4;
  justify-content: space-between;
  .post-left {
    width: 60%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    .hot-title {
      font-size: 16px;
      color: #333;
    }
    .bom-info {
      .common_bomInfo();
    }
  }
  .post-right {
    width: 40%;
    img {
      width: 100%;
      height: 20.833vw;
      object-fit: cover;
    }
  }
}
.postsTwo {
  .common_posts();
  .title {
    .common_title();
  }
  .center_img {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 4px 0;
    img {
      width: 31.111vw;
      height: 20.556vw;
    }
  }
  .bom-info {
    .common_bomInfo();
  }
}
// 样式三
.postsThree {
  .common_posts();
  .title {
    .common_title();
  }
  .center_video {
    position: relative;
    width: 100%;
    background-color: #f7f7f7;
    margin: 3.333vw 0 5vw 0;
    img {
      width: 100%;
      height: 47.222vw;
    }
    span {
      position: absolute;
      left: 40%;
      top: 33%;
      font-size: 12.778vw;
      color: #fff;
      width: 15.278vw;
      height: 15.278vw;
      line-height: 15.278vw;
      text-align: center;
      background-color: rgba(0, 0, 0, 0.3);
      border-radius: 50%;
    }
  }
  .bom-info {
    .common_bomInfo();
  }
}
</style>